package org.hzz.promotions.types.req;

import com.alibaba.fastjson2.annotation.JSONField;
import io.gitee.pkmer.fastjson2.enums.BaseEnumReader;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import org.hzz.promotions.types.enums.coupon.IssueType;
import org.hzz.promotions.types.enums.coupon.TermType;

import java.time.LocalDateTime;

/**
 * @author <a href="mailto:1193094618@qq.com">pkmer</a>
 * <br>
 * <a href = "https://gitee.com/developeros/videos-online">Code Repository</a>
 * At 2024/8/30
 * 发布优惠券请求
 */
@Data
public class IssueCouponReq {

    // 立即发放分组
    public interface IssueNowGroup {
    }

    // 定时发布分组
    public interface IssueLaterGroup {
    }

    // 有效期为固定天数
    public interface TermDaysGroup {
    }

    // 有效时间为固定时间段
    public interface TermTimeGroup {
    }

    @Schema(description = "发放方式",example = "2")
    @JSONField(deserializeUsing = BaseEnumReader.class)
    @NotNull(groups = {IssueNowGroup.class, IssueLaterGroup.class})
    private IssueType issueType;

    /**
     * 如果为空说明为立即方法
     */
    @Schema(description = "开始发放时间")
    @NotNull(groups = {IssueLaterGroup.class})
    private LocalDateTime issueBeginTime;

    @Schema(description = "结束发放时间",example = "2024-08-31 01:30:55")
    @NotNull(groups = {IssueNowGroup.class, IssueLaterGroup.class})
    private LocalDateTime issueEndTime;

    @Schema(description = "有效期类型",example = "0")
    @JSONField(deserializeUsing = BaseEnumReader.class)
    @NotNull(groups = {TermDaysGroup.class, TermTimeGroup.class})
    private TermType termType;

    /**
     * 有效天数为空说明，使用的是开始时间和结束时间
     */
    @Schema(description = "优惠券有效期天数，0：表示有效期是指定有效期的")
    @NotNull(groups = {TermDaysGroup.class})
    private Integer termDays;

    @Schema(description = "优惠券有效期开始时间")
    @NotNull(groups = {TermTimeGroup.class})
    private LocalDateTime termBeginTime;

    @Schema(description = "优惠券有效期结束时间")
    @NotNull(groups = {TermTimeGroup.class})
    private LocalDateTime termEndTime;
}
